const Mock = require('mockjs')
const { spitOutCity } = require(`${globalThis.src}/utils/helper`)

const [city, cityChild] = spitOutCity()

const data = Mock.mock({
  id: '@guid',
  level: 1,
  remark: '系统接入',
  city,
  createTime: '@datetime("2023-MM-dd 10:mm:ss")',
  'children|3': ctx => {
    const length = ctx.rule.count
    return Array.from({ length }, () => {
      return {
        id: '@guid',
        level: 2,
        remark: '子系统接入',
        'platform|1': ['视频审计', '图像审计', '视图库'],
        'city|1': cityChild,
        createTime: '@datetime("2023-MM-dd HH:mm:ss")',
      }
    })
  },
})

module.exports = {
  type: 'POST',
  response: config => {
    return {
      code: 200,
      data: { ...data },
    }
  },
}
